//
//  Status.swift
//  MicroBlog
//
//  Created by  NorthCity on 15/11/8.
//  Copyright © 2015年  NorthCity. All rights reserved.
//

import UIKit
///微博数据模型
class Status: NSObject {

    /// 微博创建时间
    var created_at: String?
    /// 微博ID
    var id: Int = 0
    /// 微博信息内容
    var text: String?
    /// 微博来源
    var source: String?
    /// 用户
    var user:User?
    /// 图片url数组
    var pic_urls:[[String:String]]?
    /// 转发微博信息字段
    var retweeted_status:Status?
    
    init(dict:[String:AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
//    MARK: - 重写 setValueForKey
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            if let dict = value as? [String:AnyObject]{
                user = User(dict: dict)
            }
            return
        }
        
        if key == "retweeted_status"{
            if let dict = value as? [String:AnyObject]{
                retweeted_status =  Status(dict:dict)
            }
            return
        }
        super.setValue(value, forKey: key)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
   override var description: String{
        let keys = ["created_at","id","text","source","user","pic_urls","retweeted_status"];
        return dictionaryWithValuesForKeys(keys).description
    }
    
}
